<?php
namespace app\api\controller;

use think\Controller;
use think\Request;
use app\api\model\StatisticsModel;
use think\Db;
use app\api\model\ArrayPaginate;
class Statistics extends Common
{
    use ArrayPaginate;
    /**
     * 采购报表---采购明细
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function Purchase(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getPurchaseList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**
     * 采购报表---按单品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PurchaseSingle(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getPurchaseSingleList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**采购报表---按单据汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PurchaseBill(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $list = $model->getPurchaseBillList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**采购报表---按商品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PurchaseGoods(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getPurchaseGoodsList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**采购报表---按供应商汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PurchaseSupplier(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getPurchaseSupplierList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**采购报表---按采购员汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PurchaseMaker(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getPurchaseMakerList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**销售报表---销售明细
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function Sale(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getSaleList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**销售报表---按单品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function SaleSingle(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getSaleSingleList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**销售报表---按商品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function SaleGoods(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getSaleGoodsList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**销售报表---按单据汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function SaleBill(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $list = $model->getSaleBillList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**销售报表---按客户汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function SaleCustom(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $list = $model->getSaleCustomList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**销售报表---按销售员汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function SalePerson(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getSalePersonList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**销售报表---按销售员所属门店汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function SaleStore(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getSaleStoreList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**销售报表---按销售员所属门店汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function WareStore(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getWareStoreList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**盘点报表---盘点明细
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function Inventory(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getInventoryList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**盘点报表---按盘点单汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function InventoryBill(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $list = $model->getInventoryBillList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**盘点报表---按商品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function InventoryGoods(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getInventoryGoodsList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**盘点报表---按仓库汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function InventoryWare(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getInventoryWareList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**调拨报表---调拨明细
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function Allot(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getAllotList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**调拨报表---按调拨单汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function AllotBill(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['des'] =isset($data['des'])?$data['des']:"";
        $list = $model->getAllotBillList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**调拨报表---按调拨单汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function AllotGoods(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getAllotGoodsList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**调拨报表---按仓库汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function AllotWare(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getAllotWareList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**生产报表---
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function Production(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getProductionList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**生产报表---按单据汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function ProductionBill(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['des'] =isset($data['name'])?$data['des']:"";
        $list = $model->getProductionBillList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**生产报表---按商品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function ProductionGoods(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getProductionGoodsList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**生产报表---按仓库汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function ProductionWare(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getProductionWareList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**配货报表----配货明细
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function Prepare(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getPrepareList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**配货报表----按单品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PrepareSingle(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getPrepareSingleList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**配货报表----按商品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PrepareGoods(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getPrepareGoodsList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**配货报表----按单据汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PrepareBill(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $list = $model->getPrepareBillList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**配货报表----按门店汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PrepareStore(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getPrepareStoreList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**配货报表----按仓管员汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PrepareKeeper(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getPrepareKeeperList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**配货报表----按仓库所属门店汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function PrepareWareStore(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getPrepareWareStoreList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**出库报表----出库明细
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function OutStock(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $data['des'] =isset($data['des'])?$data['des']:"";
        $list = $model->getOutStockList($data);
        $list =$this->StatisticsPaginate($list, $data['page'], $data['size']);
        if (!empty($list)) {
            return $this->returnJson(200, 'ok', $list);
        } else {
            return $this->returnJson('500','失败');
        }
    }

    /**出库报表----按单品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function OutStockSingle(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getOutStockSingleList($data);
        $list =$this->StatisticsPaginate($list, $data['page'], $data['size']);
        if (!empty($list)) {
            return $this->returnJson(200, 'ok', $list);
        } else {
            return $this->returnJson('500','失败');
        }
    }

    /**出库报表----按商品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function OutStockGoods(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getOutStockGoodsList($data);
        $list =$this->StatisticsPaginate($list, $data['page'], $data['size']);
        if (!empty($list)) {
            return $this->returnJson(200, 'ok', $list);
        } else {
            return $this->returnJson('500','失败');
        }
    }

    /**出库报表----按客户汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function OutStockCustom(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getOutStockCustomList($data);
        $list =$this->StatisticsPaginate($list, $data['page'], $data['size']);
        if (!empty($list)) {
            return $this->returnJson(200, 'ok', $list);
        } else {
            return $this->returnJson('500','失败');
        }
    }

    /**入库报表----入库明细
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function InStock(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['number'] =isset($data['number'])?$data['number']:"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $data['des'] =isset($data['des'])?$data['des']:"";
        $list = $model->getInStockList($data);
        $list =$this->StatisticsPaginate($list, $data['page'], $data['size']);
        if (!empty($list)) {
            return $this->returnJson(200, 'ok', $list);
        } else {
            return $this->returnJson('500','失败');
        }
    }

    /**入库报表----按单品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function InStockSingle(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getInStockSingleList($data);
        $list =$this->StatisticsPaginate($list, $data['page'], $data['size']);
        if (!empty($list)) {
            return $this->returnJson(200, 'ok', $list);
        } else {
            return $this->returnJson('500','失败');
        }
    }

    /**入库报表----按商品汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function InStockGoods(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getInStockGoodsList($data);
        $list =$this->StatisticsPaginate($list, $data['page'], $data['size']);
        if (!empty($list)) {
            return $this->returnJson(200, 'ok', $list);
        } else {
            return $this->returnJson('500','失败');
        }
    }

    /**入库报表----按供应商汇总
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function InStockSupplier(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $list = $model->getInStockSupplierList($data);
        $list =$this->StatisticsPaginate($list, $data['page'], $data['size']);
        if (!empty($list)) {
            return $this->returnJson(200, 'ok', $list);
        } else {
            return $this->returnJson('500','失败');
        }
    }

    /**商品分析----
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function Analys(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getAnalysList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    /**进销对比----
     * @param Request $request
     * @param StatisticsModel $model
     * @return \think\response\Json
     */
    public function Contrast(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time'])?strtotime($data['start_time']):"";
        $data['end_time'] =isset($data['end_time'])?strtotime($data['end_time']):"";
        $data['name'] =isset($data['name'])?$data['name']:"";
        $list = $model->getContrastList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }

    public function Revenue(Request $request,StatisticsModel $model)
    {
        $data =$request->param();
        $data['start_time'] =isset($data['start_time']) ? $data['start_time'] : "";
        $data['end_time'] =isset($data['end_time']) ? $data['end_time'] : "";
        $list = $model->getRevenueList($data);
        if (!empty($list)) {
            return json(['code' => 200, 'msg' => '成功', 'list' => $list]);
        } else {
            return json(['code' => 500, 'msg' => '失败']);
        }
    }
}